import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

import roleRouter from './modules/role'

const asyncRouter = [roleRouter]

export const constantRoutes = [
  {
    path: '/meilin/:id',
    component: () => import('@/views/xsmeilin/index.vue'),
    hidden: true
  },

  {
    path: '/newDashboard',
    component: () => import('@/views/dashboard/index')
  },

  {
    path: '/',
    component: Layout,
    redirect: '/newDashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index'),
        meta: { title: 'Dashboard', icon: 'dashboard' }
      }
    ]
  }
]

const createRouter = () => new Router({
  mode: 'history',
  base: '/demonstrate',
  scrollBehavior: () => ({ y: 0 }),
  routes: [...constantRoutes, ...asyncRouter]
})

const router = createRouter()

// export function resetRouter() {
//   const newRouter = createRouter()
//   router.matcher = newRouter.matcher
// }

export default router
